﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Data;

namespace Fayshine.VA.Helpers
{
    public enum FilterOperation
    {
        // Summary:
        //     Left operand must be smaller than the right one
        IsLessThan = 0,
        //
        // Summary:
        //     Left operand must be smaller than or equal to the right one
        IsLessThanOrEqualTo = 1,
        //
        // Summary:
        //     Left operand must be equal to the right one
        IsEqualTo = 2,
        //
        // Summary:
        //     Left operand must be different from the right one
        IsNotEqualTo = 3,
        //
        // Summary:
        //     Left operand must be larger than the right one
        IsGreaterThanOrEqualTo = 4,
        //
        // Summary:
        //     Left operand must be larger than or equal to the right one
        IsGreaterThan = 5,
        //
        // Summary:
        //     Left operand must start with the right one
        StartsWith = 6,
        //
        // Summary:
        //     Left operand must end with the right one
        EndsWith = 7,
        //
        // Summary:
        //     Left operand must contain the right one
        Contains = 8,
        //
        // Summary:
        //     Left operand must be contained in the right one
        IsContainedIn = 9,

        None = 10,
    }
    public class FilterOperatorToMarkConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            FilterOperation filter = (FilterOperation)value;
            switch (filter)
            {
                case FilterOperation.Contains:
                    return "-|-";
                case FilterOperation.EndsWith:
                    return "-|";
                case FilterOperation.IsContainedIn:
                    return "|-|";
                case FilterOperation.IsEqualTo:
                    return "==";
                case FilterOperation.IsGreaterThan:
                    return ">";
                case FilterOperation.IsGreaterThanOrEqualTo:
                    return ">=";
                case FilterOperation.IsLessThan:
                    return "<";
                case FilterOperation.IsLessThanOrEqualTo:
                    return "<=";
                case FilterOperation.IsNotEqualTo:
                    return "!=";
                case FilterOperation.StartsWith:
                    return "|-";
            }
            return string.Empty;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
    public class FilterOperatorToTextConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            FilterOperation filter = (FilterOperation)value;
            switch (filter)
            {
                case FilterOperation.Contains:
                    return "Contains";
                case FilterOperation.EndsWith:
                    return "EndsWith";
                case FilterOperation.IsContainedIn:
                    return "IsContainedIn";
                case FilterOperation.IsEqualTo:
                    return "IsEqualTo";
                case FilterOperation.IsGreaterThan:
                    return "IsGreaterThan";
                case FilterOperation.IsGreaterThanOrEqualTo:
                    return "IsGreaterThanOrEqualTo";
                case FilterOperation.IsLessThan:
                    return "IsLessThan";
                case FilterOperation.IsLessThanOrEqualTo:
                    return "IsLessThanOrEqualTo";
                case FilterOperation.IsNotEqualTo:
                    return "IsNotEqualTo";
                case FilterOperation.StartsWith:
                    return "StartsWith";
            }
            return string.Empty;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
